package com.ruoyi.finances.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.finances.domain.TbAbstract;
import com.ruoyi.finances.domain.TbCertFilcateWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finances.domain.TbProof;
import com.ruoyi.finances.service.ITbProofService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 凭证设置Controller
 *
 * @author ruoyi
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/proof")
public class TbProofController extends BaseController
{
    @Autowired
    private ITbProofService tbProofService;

    /**
     * 查询摘要表
     * @param tbProof
     * @return
     */
    @GetMapping("/FindAbstract")
    public TableDataInfo FindAbstract(){

        List<TbAbstract> list = tbProofService.FindAbstract();
        return getDataTable(list);
    }

    @GetMapping("/FindWord")
    public TableDataInfo FindWord(){



        List<TbCertFilcateWord> list = tbProofService.FindWord();
        return getDataTable(list);
    }

    /**
     * 查询凭证设置列表
     */
    @RequiresPermissions("proof:proof:list")
    @GetMapping("/list")
    public TableDataInfo list(TbProof tbProof)
    {
        startPage();
        List<TbProof> list = tbProofService.selectTbProofList(tbProof);
        return getDataTable(list);
    }

    /**
     * 导出凭证设置列表
     */
    @RequiresPermissions("proof:proof:export")
    @Log(title = "凭证设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbProof tbProof)
    {
        List<TbProof> list = tbProofService.selectTbProofList(tbProof);
        ExcelUtil<TbProof> util = new ExcelUtil<TbProof>(TbProof.class);
        util.exportExcel(response, list, "凭证设置数据");
    }

    /**
     * 获取凭证设置详细信息
     */
    @RequiresPermissions("proof:proof:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbProofService.selectTbProofById(id));
    }

    /**
     * 新增凭证设置
     */
    @RequiresPermissions("proof:proof:add")
    @Log(title = "凭证设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbProof tbProof)
    {
        return toAjax(tbProofService.insertTbProof(tbProof));
    }

    /**
     * 修改凭证设置
     */
    @RequiresPermissions("proof:proof:edit")
    @Log(title = "凭证设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbProof tbProof)
    {
        return toAjax(tbProofService.updateTbProof(tbProof));
    }

    /**
     * 删除凭证设置
     */
    @RequiresPermissions("proof:proof:remove")
    @Log(title = "凭证设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbProofService.deleteTbProofByIds(ids));
    }
}
